﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Forecast.aspx.cs" Inherits="ImgForecast.admin.Forecast" %>

<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="cc1" %>
<%@ Register Assembly="obout_Interface" Namespace="Obout.Interface" TagPrefix="cc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <link href="../grid/resources/custom_scripts/column-set/column-set.css" rel="stylesheet"
        type="text/css" />
        <script  language="C#" runat="server">
                protected void OnGridRowDataBound(object sender, GridRowEventArgs args)
        {
            double sep = args.Row.Cells[4].Text == "" ? 0 : Convert.ToDouble(args.Row.Cells[4].Text);
            double oct = args.Row.Cells[5].Text == "" ? 0 : Convert.ToDouble(args.Row.Cells[5].Text);
            double nov = args.Row.Cells[6].Text == "" ? 0 : Convert.ToDouble(args.Row.Cells[6].Text);
            double dec = args.Row.Cells[7].Text == "" ? 0 : Convert.ToDouble(args.Row.Cells[7].Text);
            double total2012 = sep + oct + nov + dec;
            args.Row.Cells[8].Text = total2012.ToString();
            //args.Row.Cells[0].BackColor = System.Drawing.Color.LightGray;
            
            //if (args.Row.Cells[4].Text == "USA" || args.Row.Cells[4].Text == "Denmark" || args.Row.Cells[4].Text == "Germany")
            //{
            //    for (int i = 1; i < args.Row.Cells.Count; i++)
            //    {
            //        args.Row.Cells[i].BackColor = System.Drawing.Color.DarkGray;
            //    }
            //}

        }
        </script>
    <cc1:Grid ID="Grid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnRowDataBound="OnGridRowDataBound">
        <Columns>
            <cc1:Column DataField="ForecastID" HeaderText="ForecastID" Width="80" ReadOnly="true" Visible="false">
            </cc1:Column>
            <cc1:Column DataField="UserID" HeaderText="UserID" Width="80">
            </cc1:Column>
            <cc1:Column DataField="ArtistID" HeaderText="ArtistID" Width="80">
            </cc1:Column>
            <cc1:Column DataField="CurrencyID" HeaderText="CurrencyID" Width="80">
            </cc1:Column>
            <cc1:Column DataField="Sep2012" HeaderText="Sep2012" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Oct2012" HeaderText="Oct2012" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Nov2012" HeaderText="Nov2012" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Dec2012" HeaderText="Dec2012" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Total2012" Width="100" DataFormatString="{0:C2}">
                
        </cc1:Column>
            <cc1:Column DataField="Jan2013" HeaderText="Jan2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Feb2013" HeaderText="Feb2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Mar2013" HeaderText="Mar2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Apr2013" HeaderText="Apr2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="May2013" HeaderText="May2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Jun2013" HeaderText="Jun2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Jul2013" HeaderText="Jul2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Aug2013" HeaderText="Aug2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Sep2013" HeaderText="Sep2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Oct2013" HeaderText="Oct2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Nov2013" HeaderText="Nov2013" Width="100" DataFormatString="{0:C2}">
            </cc1:Column>
            <cc1:Column DataField="Dec2013" HeaderText="Dec2013" Width="100" DataFormatString="{0:C2}">
            
            </cc1:Column>
        </Columns>
        <Templates>
                <cc1:GridTemplate runat="server" ID="Total2012Template" ControlID="TotalPrice">
               <Template> 
               
               </Template>
        </cc1:GridTemplate>
        </Templates>
    </cc1:Grid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
        DeleteCommand="DELETE FROM [Forecasts] WHERE [ForecastID] = @ForecastID" InsertCommand="INSERT INTO [Forecasts] ([UserID], [ArtistID], [CurrencyID], [Sep2012], [Oct2012], [Nov2012], [Dec2012], [Sep2013], [Aug2013], [Jul2013], [Jun2013], [May2013], [Apr2013], [Mar2013], [Feb2013], [Jan2013], [Oct2013], [Nov2013], [Dec2013]) VALUES (@UserID, @ArtistID, @CurrencyID, @Sep2012, @Oct2012, @Nov2012, @Dec2012, @Sep2013, @Aug2013, @Jul2013, @Jun2013, @May2013, @Apr2013, @Mar2013, @Feb2013, @Jan2013, @Oct2013, @Nov2013, @Dec2013)"
        SelectCommand="SELECT [ForecastID], [UserID], [ArtistID], [CurrencyID], [Sep2012], [Oct2012], [Nov2012], [Dec2012], [Sep2013], [Aug2013], [Jul2013], [Jun2013], [May2013], [Apr2013], [Mar2013], [Feb2013], [Jan2013], [Oct2013], [Nov2013], [Dec2013] FROM [Forecasts]"
        UpdateCommand="UPDATE [Forecasts] SET [UserID] = @UserID, [ArtistID] = @ArtistID, [CurrencyID] = @CurrencyID, [Sep2012] = @Sep2012, [Oct2012] = @Oct2012, [Nov2012] = @Nov2012, [Dec2012] = @Dec2012, [Sep2013] = @Sep2013, [Aug2013] = @Aug2013, [Jul2013] = @Jul2013, [Jun2013] = @Jun2013, [May2013] = @May2013, [Apr2013] = @Apr2013, [Mar2013] = @Mar2013, [Feb2013] = @Feb2013, [Jan2013] = @Jan2013, [Oct2013] = @Oct2013, [Nov2013] = @Nov2013, [Dec2013] = @Dec2013 WHERE [ForecastID] = @ForecastID">
        <DeleteParameters>
            <asp:Parameter Name="ForecastID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="UserID" Type="String" />
            <asp:Parameter Name="ArtistID" Type="Int32" />
            <asp:Parameter Name="CurrencyID" Type="Int32" />
            <asp:Parameter Name="Sep2012" Type="Decimal" />
            <asp:Parameter Name="Oct2012" Type="Decimal" />
            <asp:Parameter Name="Nov2012" Type="Decimal" />
            <asp:Parameter Name="Dec2012" Type="Decimal" />
            <asp:Parameter Name="Sep2013" Type="Decimal" />
            <asp:Parameter Name="Aug2013" Type="Decimal" />
            <asp:Parameter Name="Jul2013" Type="Decimal" />
            <asp:Parameter Name="Jun2013" Type="Decimal" />
            <asp:Parameter Name="May2013" Type="Decimal" />
            <asp:Parameter Name="Apr2013" Type="Decimal" />
            <asp:Parameter Name="Mar2013" Type="Decimal" />
            <asp:Parameter Name="Feb2013" Type="Decimal" />
            <asp:Parameter Name="Jan2013" Type="Decimal" />
            <asp:Parameter Name="Oct2013" Type="Decimal" />
            <asp:Parameter Name="Nov2013" Type="Decimal" />
            <asp:Parameter Name="Dec2013" Type="Decimal" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="UserID" Type="String" />
            <asp:Parameter Name="ArtistID" Type="Int32" />
            <asp:Parameter Name="CurrencyID" Type="Int32" />
            <asp:Parameter Name="Sep2012" Type="Decimal" />
            <asp:Parameter Name="Oct2012" Type="Decimal" />
            <asp:Parameter Name="Nov2012" Type="Decimal" />
            <asp:Parameter Name="Dec2012" Type="Decimal" />
            <asp:Parameter Name="Sep2013" Type="Decimal" />
            <asp:Parameter Name="Aug2013" Type="Decimal" />
            <asp:Parameter Name="Jul2013" Type="Decimal" />
            <asp:Parameter Name="Jun2013" Type="Decimal" />
            <asp:Parameter Name="May2013" Type="Decimal" />
            <asp:Parameter Name="Apr2013" Type="Decimal" />
            <asp:Parameter Name="Mar2013" Type="Decimal" />
            <asp:Parameter Name="Feb2013" Type="Decimal" />
            <asp:Parameter Name="Jan2013" Type="Decimal" />
            <asp:Parameter Name="Oct2013" Type="Decimal" />
            <asp:Parameter Name="Nov2013" Type="Decimal" />
            <asp:Parameter Name="Dec2013" Type="Decimal" />
            <asp:Parameter Name="ForecastID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <script src="../grid/resources/custom_scripts/column-set/column-set.js" type="text/javascript"></script>
        <script type="text/javascript">
            window.onload = function () {
                //Grid1.addColumnSet(level, startColumnIndex, endColumnIndex, text);
                Grid1.addColumnSet(0, 0, 3, '');
                Grid1.addColumnSet(0, 4, 8, '2012');
                Grid1.addColumnSet(0, 9, 20, '2013');
                Grid1.addColumnSet(1, 0, 3, '');
                Grid1.addColumnSet(1, 4, 4, 'Q3');
                Grid1.addColumnSet(1, 5, 7, 'Q4');
                Grid1.addColumnSet(1, 8, 10, 'Q1');
                Grid1.addColumnSet(1, 11, 13, 'Q2');
                Grid1.addColumnSet(1, 14, 16, 'Q3');
                Grid1.addColumnSet(1, 17, 19, 'Q4');
            }

            function calculateTotal() {
                TotalPrice.value(parseFloat(Oct2012.value()) * parseFloat(Nov2012.value()));
            }
    </script>
</asp:Content>
